package com.controller;

import com.dao.AccountDao;
import com.pojo.Account;
import com.pojo.Teacher;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Controller
public class AccountController {

    @Autowired
    private AccountDao accountDao;

    @Autowired
    @Qualifier("getAccount")
    private Account acc;

    @Autowired
    private Teacher t;

    @RequestMapping("/aa.do")
    public String getAcc(){
        System.out.println(acc.getName()+" "+acc.getAid());
        System.out.println(t.getName()+" "+t.getAge());
        return "xx";
    }

    @RequestMapping("/showAccount.do")
    public String showAccount(Account acc, Map map){
        List<Account> list = accountDao.getAllAccount(acc);
        map.put("list",list);
        return "showAccount.html";
    }

    @RequestMapping("/login.do")
    public String login(HttpSession session){
        System.out.println("执行了登录方法");
        session.setAttribute("dqyh","xxxx");
        return "showlogin.html";
    }

    @RequestMapping("/logout.do")
    public String logout(HttpSession session){
        System.out.println("执行了登出方法");
        session.removeAttribute("dqyh");
        return "showlogin.html";
    }
}
